//
//  SettingModel.swift
//  BasicTools
//
//  Created by ikang on 2025/8/26.
//

import Foundation
import SwiftUI

public enum SettingType {
    // title 和 subTitle 横向排列
    case titleHStack
    // title 和 subTitle 纵向排列
    case titleVStack
    
    case toggle
}

@Observable public class SettingItemModel {
    // item样式
    public var type: SettingType = .titleHStack
    
    public var title: String = ""
    public var subTitle: String = ""
    public var leftImage: String = ""
    public var rightImage: String = ""
    
    public var isOn: Bool = false
    
    // 下一页，或者下一项的数据
    public var sectionArr: [SettingSectionModel] = []
    
    public init(title: String = "", 
                subTitle: String = "", 
                leftImage: String = "",
                rightImage: String = "",
                type: SettingType = .titleHStack,
                sectionArr: [SettingSectionModel] = []) {
        self.type = type
        self.title = title
        self.subTitle = subTitle
        self.leftImage = leftImage
        self.rightImage = rightImage
        self.sectionArr = sectionArr
    }
}

@Observable public class SettingSectionModel: ObservableObject {
    public var headerTitle: String = ""
    public var itemArr: [SettingItemModel] = []
    
    public init(headerTitle: String = "",
                itemArr: [SettingItemModel] = []) {
        self.headerTitle = headerTitle
        self.itemArr = itemArr
    }
}

@Observable public class SettingDataModel {
    public var sectionArr: [SettingSectionModel] = []
    
    public init() { }
}


// 设置Model
@Observable public class SettingModel {
    static public var shared: SettingModel = SettingModel()
    
    // 设置list
    public var listBackgroundColor: Color = .gray
    public var listPadding: EdgeInsets = EdgeInsets(top: 20, leading: 20, bottom: 20, trailing: 20)
    
    // 设置section
    public var sectionBackgroundColor: Color = .white
    public var sectionCornerRadius: CGFloat = 15
    public var sectionSpace: CGFloat = 10
    public var headerTitleFont: Font = .system(size: 15)
    public var headerTitleColor: Color = .black
    public var headerPadding: EdgeInsets = EdgeInsets(top: 10, leading: 15, bottom: 10, trailing: 15)
    
    // 设置item
    public var itemPadding: EdgeInsets = EdgeInsets(top: 10, leading: 15, bottom: 10, trailing: 15)
    public var titleFont: Font = .system(size: 14)
    public var titleColor: Color = .black
    public var subTitleFont: Font = .system(size: 12)
    public var subTitleColor: Color = .gray
    public var leftImageSize: CGSize = CGSize(width: 30, height: 30)
    public var rightImageSize: CGSize = CGSize(width: 10, height: 10)
    
    public var itemHSpace: CGFloat = 5
    public var itemTitleSpace: CGFloat = 5
    public var itemLinePadding: EdgeInsets = EdgeInsets(top: 0, leading: 15, bottom: 0, trailing: 15)
    public var itemLineColor: Color = .gray
    public var itemLineHeight: CGFloat = 0.5
    
    public init() { }
}

